package com.gitee.kinbug.sniper.web.device;

import java.math.BigDecimal;
import java.math.RoundingMode;

import com.gitee.kinbug.sniper.common.enums.CandleEnum;

import lombok.Data;

@Data
/**
 * 分值估算模型
 * @author kinbug
 */
public class SeriesModel {

	private Index index;

	public SeriesModel(Index index) {
		this.index = index;
	}

	/**
	 * 买跌
	 * 
	 * @author kinbug
	 * @param price 当前价格
	 * @return BigDecimal 返回评分
	 */
	public BigDecimal buyDnRiskPts() {
		BigDecimal price = index.getClosePrice();
		// 5分钟
		BigDecimal rsiPts5 = new BigDecimal(25).multiply(index.getRsi(CandleEnum.MIN5)).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPts5 = new BigDecimal(10).multiply(index.getBoll(CandleEnum.MIN5).getBuyDnWinRate(price));
		// 15分钟
		BigDecimal rsiPts15 = new BigDecimal(25).multiply(index.getRsi(CandleEnum.MIN15)).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPts15 = new BigDecimal(10).multiply(index.getBoll(CandleEnum.MIN15).getBuyDnWinRate(price));
		// 1小时
		BigDecimal rsiPtsH1 = new BigDecimal(10).multiply(index.getRsi(CandleEnum.HOUR1)).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPtsH1 = new BigDecimal(5).multiply(index.getBoll(CandleEnum.HOUR1).getBuyDnWinRate(price));
		// 4小时
		BigDecimal rsiPtsH4 = new BigDecimal(10).multiply(index.getRsi(CandleEnum.HOUR4)).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPtsH4 = new BigDecimal(5).multiply(index.getBoll(CandleEnum.HOUR4).getBuyDnWinRate(price));
		// 计算总分
		BigDecimal countPts = rsiPts5.add(rsiPts15).add(rsiPtsH1).add(rsiPtsH4).add(bollPts5).add(bollPts15).add(bollPtsH1).add(bollPtsH4);
		return countPts;
	}

	/**
	 * 买涨
	 * 
	 * @author kinbug
	 * @param price 当前价格
	 * @return BigDecimal 返回评分
	 */
	public BigDecimal buyUpRiskPts() {
		BigDecimal price = index.getClosePrice();
		BigDecimal rsiPts5 = new BigDecimal(25).multiply(new BigDecimal(100).subtract(index.getRsi(CandleEnum.MIN5))).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPts5 = new BigDecimal(10).multiply(index.getBoll(CandleEnum.MIN5).getBuyUpWinRate(price));
		// 15分钟
		BigDecimal rsiPts15 = new BigDecimal(25).multiply(new BigDecimal(100).subtract(index.getRsi(CandleEnum.MIN15))).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPts15 = new BigDecimal(10).multiply(index.getBoll(CandleEnum.MIN15).getBuyUpWinRate(price));
		// 1小时
		BigDecimal rsiPtsH1 = new BigDecimal(10).multiply(new BigDecimal(100).subtract(index.getRsi(CandleEnum.HOUR1))).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPtsH1 = new BigDecimal(5).multiply(index.getBoll(CandleEnum.HOUR1).getBuyUpWinRate(price));
		// 4小时
		BigDecimal rsiPtsH4 = new BigDecimal(10).multiply(new BigDecimal(100).subtract(index.getRsi(CandleEnum.HOUR4))).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
		BigDecimal bollPtsH4 = new BigDecimal(5).multiply(index.getBoll(CandleEnum.HOUR4).getBuyUpWinRate(price));
		// 计算总分
		BigDecimal countPts = rsiPts5.add(rsiPts15).add(rsiPtsH1).add(rsiPtsH4).add(bollPts5).add(bollPts15).add(bollPtsH1).add(bollPtsH4);
		return countPts;
	}
}
